package 子数组系列;

public class test1 {

    public int maxSubArray(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n+1];
        int flag = Integer.MIN_VALUE;
        for (int i = 1; i <= n; i++) {
            dp[i] = Math.max(nums[i-1],dp[i-1]+nums[i-1]);
            flag = Math.max(dp[i],flag);
        }
        return flag;
    }
}
